# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
海拍客存放api接口信息。以dict形式存放，这样就可以API_ALL[''][url]这种方式去取，看起来较直观，知道取得是哪个接口的那部分信息
#文件：hipac_api.py
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

import json
from pycacho.cachobase.deal_time import minus_date

c_date = minus_date(0,'q')       # '%Y%m%d%H%M%S'
c_time = minus_date(0,'qt')    # '%Y-%m-%d %H:%M:%S'

API_HPK={
    # 授信申请 补件信息
    "apply_message": {
        "requestId": "CN" + c_date,
        "partnerNo": "hpk",                # 合作方编号：固定值
        "merchantNo": "SH" + c_date,
        "registeredDays": 10,              # 注册有效天数
        #"firstOrderTime":  c_time,         # 第一笔订单时间 YYYY-MM-DD HH:mm:ss
        "lastOrderTime":  c_time,          # 最近一笔订单时间
        "orderMonthsInOneYear": '3',        # 近一年有效订单月份：1,2,3月都有订单
        "orderMonthsInHalfAYear": 6,        # 近半年产生订单的月份总和
        "totalOrdersInOneYear": 10,        # 近一年总订单数
        "totalOrdersInSixMonths": 8,       # 近六个月的订单总数
        "totalOrdersInThreeMonths": 6,     # 近三个月的订单总数
        "totalOrdersInOneMonth": 2,        # 近一个月的订单总数
        "totalOrderAmountInOneYear": 60000.00,     # 近一年总订单额
        "totalOrderAmountInSixMonths": 30000.00,   # 近六个月总订单额
        "maxOrderAmountInSixMonths": 5000.00,      # 近六个月最大订单额
        "totalOrderAmountInThreeMonths": 20000.00, # 近三个月总订单额
        "totalOrderAmountInOneMonth": 5000.00,     # 近一个月总订单额
        "totalRefundOrdersInOneYear": 2,           # 近一年的退货订单总数
        "totalRefundAmountInOneYear": 5000.00,     # 近一年退货总额
        "totalRefundAmountInOneMonth": 2000.00,     # 近一个月退货总额
        "postAddress":  "测试地址xxx",               # 送货地址
        "shopName":  "测试地址1"                   # 门店名称
    },
    # 授信通知
    "credit_notice":{
        "requestId":  "CN" + c_date,      # 进件申请的流水号，原路返回
        "creditNo":  "CW" + c_date ,      # 授信流水号
        "merchantNo":  "123456",
        "creditStatus":  1,               # 1-授信成功，2-授信拒绝
        "message":  "授信成功",
        "creditAmount":  "5000.00",
        "creditDate":  "2019-12-31",
        "creditExpires":  "2020-06-30"   # 授信失效日期
    },
    # 商户额度查询
    "limit_query": {
        "requestId": "CN" + c_date,     # 用信申请流水号，原路返回
        "partnerNo": '20200106002647',  # 借款流水号
        "mchNo": '',
    },
    # 还款通知
    "repay_notice": {
        "requestId": "CN" + c_date,    # 用信申请流水号，原路返回
        "loanNo": "RP" + c_date,       # 借款流水号
        "planId": 1,                   # 还款期数
        "repayCode": 0,                # 还款状态：0-成功，1-失败
        "message": "成功"
    },
    # 退货申请
    "refund_apply": {
        "requestId": "CN" + c_date,       # 申请流水号，原路返回
        "partnerNo": '20200106002647',    # 合作方编号
        "loanNo": 'HIPAC20200117164737574f9M8',  # 借款流水号
        "refundAmount": 200,
        "refundType": 1,                 # 非必填  0-全部退货,1-部分退货  后台根据退货金额计算退货类型
        "refundTime": minus_date(0,'t')  #    # 2020-05-14

    },
    # 退货查询
    "refund_query": {
        "requestId": "CN" + c_date,     # 用信申请流水号，原路返回
        "partnerNo": '20200106002647',  # 合作方编号
        "loanNo": 'HIPAC2020021717223388623g9',        # 借款流水号
        "refundNo": ""
    },
    # 贷款详情查询
    "loan_detail": {
        "requestId": "CN" + c_date,                  # 请求申请流水号，原路返回
        "partnerNo": '20200106002647',              # 合作方编号
        "loanNo": 'HIPAC2020021717223388623g9'       # 借款流水号
    },
    # 支付通知
    "pay_notice": {
        "requestId": "CN" + c_date,  # 用信申请流水号，原路返回
        "partner_no": '20200106002647',  # 借款流水号
        "loanNo": 0,  # 用信申请结果：0-成功，1-失败
        "refundNo": '',
    },
    # 放款申请
    "applyLoan": {
        "feeRepayFrom": 1,
        "loanAmount": 5000,
        "loanDate": "2019-11-08 12:22:33",
        "loanPeriod": 30,
        "loanPeriodType": 0,      # 借款期限类型，0-日，1-月，2-年
        "loanRemark": "zeng",
        "loanUse": 1,
        "merchantNo": "abcd",
        "partnerNo": "HIPAC",
        "password": "abcd",
        "productNo": "P0001",
        "requestId": "abcd",
        "sign": "abcd"
    },
    "notice":{
        "activeStatus":1,           # 1-激活成功、2-激活失败
        "businessLicenseUrl":"https://msbuc.oss-cn-shenzhen.aliyuncs.com/test/meson/hipac/picture/personal_info/2020-01-17/living/1579257383483.png",
        "creditAmount":0,
        "creditDate":1595473976311,
        "creditExpires":1595473976311,
        "creditStatus":1,             # 0-进件完成，授信中、1-授信成功、2-授信拒绝
        "custMobile":"15917374871",
        "custName":"曾令为",
        "foodCirculationLicenseUrl":"https://msbuc.oss-cn-shenzhen.aliyuncs.com/test/meson/hipac/picture/personal_info/2020-01-17/living/1579257390018.png",
        "merchantAddress":"北京市朝阳区塔无酒望甲1号18层B-2101",
        "merchantCode":"91440300071122857U",
        "merchantName":"深圳海水科技有限公司",
        "merchantNo":"002648",
        "message":"激活成功"
    }

}


if __name__ == '__main__':
    # json indent=缩进空格数,得到树型格式; ensure_ascii=False,不希望中文字符等被unicode转义; sort_keys=True,希望显示的字典内的字段是排过序的
    data = json.dumps(API_HPK['apply_message'],indent=4,ensure_ascii=False)
    print(data)

